﻿using System;
using Lucene.Linq.Mapping;
using Lucene.Net.Analysis;

namespace Lucene.Linq.Expressions
{
    /// <summary>
    /// Type cache for Analyzer instances
    /// </summary>
    internal class AnalyzerTypeCache : TypeCache<Analyzer>
    {
        #region Singleton

        private static readonly AnalyzerTypeCache _instance = new AnalyzerTypeCache();

        internal static AnalyzerTypeCache Instance
        {
            get { return _instance; }
        }

        #endregion

        protected override Analyzer ActivateInstance(Type type)
        {
            if (type == null)
            {
                type = Defaults.FieldAnalyzerType;
            }

            return base.ActivateInstance(type);
        }

        protected override Analyzer DefaultInstance()
        {
            return ActivateInstance(Defaults.FieldAnalyzerType);
        }
    }
}